package com.santu.edu.supporter.exception;

/**
 * @author luoyaoqi
 * @createTime 2024/2/20
 * @description
 */
public class BizException extends RuntimeException {
    private static final long serialVersionUID = -8347878473827951063L;
    private final BizError businessError;
    private String customMsg;

    BizException() {
        this.businessError = null;
    }

    public BizException(BizError error) {
        super(error.getDesc());
        this.businessError = error;
    }

    public BizException(BizError error, String customMsg) {
        super(customMsg);
        this.businessError = error;
        this.customMsg = customMsg;
    }

    public static BizException causeBy(BizError error) {
        return new BizException(error);
    }

    public static BizException causeBy(BizError error, String customMsg) {
        return new BizException(error, customMsg);
    }

    public BizError getError() {
        return this.businessError;
    }

    public String getCustomMsg() {
        return this.customMsg;
    }
}